<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>生成器-函数参数</title>
</head>
<body>
<script>
    function* fun(arg) {
        console.log(arg)
        let result1 = yield  'first';
        console.log(result1)
        let result2 = yield  'second';
        console.log(result2)
        yield 'third';
    }

    // 执行获取迭代器对象
    let iterator = fun('I')
    console.log(iterator.next())
    //使用next方法获取实参
    console.log(iterator.next('Love'))
    console.log(iterator.next(' You'))
</script>
</body>
</html>